package pyip.lib.javalearn;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RegExDemo {
	public static void main(String[] args) {
		String regex = "^[1-9][0-9]{0,7}|[1-9][0-9]{0,6}\\.[0-9]{1}|[1-9][0-9]{0,5}\\.[0-9]{2}|0\\.[1-9]{1}[0-9]{0,1}|0\\.\\d[1-9]{1}$";
		System.out.println(Pattern.matches(regex, "12345678"));
		System.out.println(Pattern.matches(regex, "1234567.0"));
		System.out.println(Pattern.matches(regex, "123456.10"));
		System.out.println(Pattern.matches(regex, "12345"));
		System.out.println(Pattern.matches(regex, "1234.56"));
		System.out.println();
		System.out.println(Pattern.matches(regex, "123456789"));
		System.out.println(Pattern.matches(regex, "12345678.0"));
		System.out.println(Pattern.matches(regex, "1234567.00"));
		System.out.println(Pattern.matches(regex, "12347.100"));
		System.out.println();
		System.out.println(Pattern.matches(regex, "0.1"));
		System.out.println(Pattern.matches(regex, "0.10"));
		System.out.println(Pattern.matches(regex, "0.01"));
		System.out.println(Pattern.matches(regex, "0.010"));
		System.out.println(Pattern.matches(regex, "0.0"));
		System.out.println(Pattern.matches(regex, "0"));
		System.out.println(Pattern.matches(regex, "."));
		
		Pattern p = Pattern.compile(regex);
		Matcher m = p.matcher("5.011");
		System.out.println("find: " + m.find());
		System.out.println("find: " + m.group());
		
//		System.out.println(Pattern.matches("^([1-9][0-9]{0,7})|(([1-9][0-9]{0,6})([.][0-9]{1}))|(([1-9][0-9]{0,5})([.][0-9]{2}))$", "."));
	}
}
